package org.fatmansoft.teach;

import org.fatmansoft.teach.service.SystemService;
import org.fatmansoft.teach.service.TestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(value = 0)  //优先级最高
public class SystemApplicationListener implements ApplicationListener<ApplicationReadyEvent> {
    private static final Logger logger = LoggerFactory.getLogger(SpringBootSecurityJwtApplication.class);
    @Autowired
    private SystemService systemService;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        //打印2022-02-24 19:10:13.842  INFO 15412 --- [           main] o.f.t.SpringBootSecurityJwtApplication   : SystemInitStart
        logger.info("SystemInitStart");  // 表示程序开始

        systemService.loadUimsFile();  // 用来读入yml文件

        //打印2022-02-24 19:10:13.938  INFO 15412 --- [           main] o.f.t.SpringBootSecurityJwtApplication   : systemInitEnd
        logger.info("systemInitEnd");    // 用来表示程序结束
    }

}
